<?php

/**
 * This is the model class for table "contact".
 *
 * The followings are the available columns in table 'contact':
 * @property integer $id
 * @property string $fullname
 * @property string $email
 * @property string $phone
 * @property string $comments
 * @property integer $office_interest
 * @property string $company
 * @property string $website
 * @property integer $inquire
 */
class ContactBase extends CActiveRecord
{
    /**
     * Returns the static model of the specified AR class.
     * @return Contact the static model class
     */
    public static function model($className='Contact')
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'contact';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('fullname, email, phone, comments, inquire', 'required'),
            array('office_interest, inquire', 'numerical', 'integerOnly'=>true),
            array('fullname, email, company, website', 'length', 'max'=>250),
            array('phone', 'length', 'max'=>15),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('fullname, email, phone, comments, office_interest, company, website, inquire, creationdatetime', 'safe', 'on'=>'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations()
    {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'id' => 'ID',
            'fullname' => 'Full Name',
            'email' => 'Email Address',
            'phone' => 'Phone Number',
            'comments' => 'Your Comments',
            'office_interest' => 'Office Location Interest',
            'company' => 'Your Company',
            'website' => 'Your Website',
            'inquire' => 'What are you inquiring about?',
            'creationdatetime'=>'Creation Time',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria=new CDbCriteria;

        $criteria->compare('id',$this->id);
        $criteria->compare('fullname',$this->fullname,true);
        $criteria->compare('email',$this->email,true);
        $criteria->compare('phone',$this->phone,true);
        $criteria->compare('comments',$this->comments,true);
        $criteria->compare('office_interest',$this->office_interest);
        $criteria->compare('company',$this->company,true);
        $criteria->compare('website',$this->website,true);
        $criteria->compare('inquire',$this->inquire);

        return new CActiveDataProvider(get_class($this), array(
            'criteria'=>$criteria,
        ));
    }
}